package org.jeecg.modules.controller.business;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.dto.device.*;
import org.jeecg.modules.service.DeviceService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author Administrator
 * @Description: 设备模块业务队列
 * @Date 2021/06/04
 * @Created by wk
 */
@Api(tags="设备模块业务队列")
@RestController
@RequestMapping("/business/device")
public class DeviceController {

    @Resource
    private DeviceService deviceService;

    @ApiOperation(value = "远程开关锁", notes = "远程开关锁")
    @GetMapping(value = "/switchLock")
    public Result<?> switchLock(SwitchLockReq switchLockReq) {
        return deviceService.switchLock(switchLockReq);
    }

    @AutoLog(value = "首页地图-开关锁",operateType = 3)
    @ApiOperation(value = "Web远程开关锁", notes = "Web远程开关锁")
    @PostMapping(value = "/switchLockWeb")
    public Result<?> switchLockWeb(@RequestBody SwitchLockReq switchLockReq) {
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        switchLockReq.setUserCode(sysUser.getId());
        return deviceService.switchLock(switchLockReq);
    }

    @ApiOperation(value = "车桩状态查询", notes = "车桩状态查询")
    @GetMapping(value = "/pileQuery")
    public Result<?> pileQuery(PileQueryReq pileQueryReq) {
        return deviceService.pileQuery(pileQueryReq);
    }

    @AutoLog(value = "车桩语音设置",operateType = 3)
    @ApiOperation(value = "车桩默认语音", notes = "车桩默认语音")
    @PostMapping(value = "/setVoice")
    public Result<?> setVoice(@RequestBody SetVoiceReq setVoiceReq) {
        return deviceService.updateVoice(setVoiceReq);
    }

}
